package com.dm.shop.mapper;

import com.dm.shop.entity.Product;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author MyBatisPlusGenerater-Saiya Wang
 * @since 2021-07-20
 */
@Mapper
@Repository
public interface ProductMapper extends BaseMapper<Product> {
    @Select("select * from product where name like concat('%',#{keyword},'%')")
    List<Product> keySearch(String keyword);

    @Insert("insert INTO product (`name`,`store`,`original_price`,`promote_price`,`stock`,`cid`,`sale_num`,`collect_num`) " +
            "VALUES (#{name},#{store},#{originalPrice},#{promotePrice},#{stock},#{cid},#{saleNum},#{collectNum})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertProduct(@Param("name") String name, @Param("store") String store,@Param("originalPrice") float originalPrice,@Param("promotePrice") float promotePrice, @Param("stock") Integer stock, @Param("cid") Integer cid,@Param("saleNum") Integer saleNum,@Param("collectNum") Integer collectNum);
}
